import en from "../i18n/lang/en"
import Vue from "vue"
import Router from "vue-router"
import CommerViews from "@/views/commerViews"
import Login from "@/views/login/index"
import Layout from "@/views/layout/layout"
import HomeMain from "@/views/index/mainIndex"

// 不是必须加载的组件使用懒加载
const Icon = () => import("@/views/icon/index")
const Erji = () => import("@/views/duoji/erji")
const Erji2 = () => import("@/views/duoji/erji2")
const Sanji = () => import("@/views/duoji/sanji")
const Sanji2 = () => import("@/views/duoji/sanji2")
const Siji = () => import("@/views/duoji/siji")
const Wuji = () => import("@/views/duoji/wuji")
const Transfer = () => import("@/views/transfer/transfer")
const DataTable = () => import("@/views/table/dataTables")
const FilterTable = () => import("@/views/table/filterTable")
const DragTable = () => import("@/views/table/dragTabe")
const Upload = () => import("@/views/upload/upload")
const Markdown = () => import("@/views/editor/markdownView")
const WangeditorView = () => import("@/views/editor/wangeditorView")
const NotFound = () => import("@/views/page404")
const AddArticle = () => import("@/views/article/addArticle")
const AddArticleEditor = () => import("@/views/article/addArticleEditor")
const NavClassify = () => import("@/views/syssetting/navClassify")
const pagePermissions = () => import("@/views/permissions/pagePermissions")
const btnPermissions = () => import("@/views/permissions/btnPermissions")

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  { path: "/",
    redirect: "/index",
    hidden: true,
    children: []
  },
  {
    path: "/login",
    component: Login,
    name: "",
    hidden: true,
    children: []
  },
  // 主页
  {
    path: "/index",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: routeName.home,
    component: Layout,
    alone: true,
    children: [
      {
        path: "/Home",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "主页",
        component:()=>import ('../views/Home'),
        children: []
      }
    ]
  },
  {
    path: "/404",
    component: NotFound,
    name: "404",
    hidden: true,
    children: []
  }
]

let addRouter = [

// 首页
 /*  {
    path: "/",
    iconCls: "el-icon-tickets", // 图标样式class
    name: routeName.article,
    component: Layout,
    children: [
      {
        path: "/addArticle",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.publishArticle,
        component: AddArticle,
        children: []
      },
      {
        path: "/addArticleEditor",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.publishArticleEditor,
        hidden: true,
        component: AddArticleEditor,
        children: []
      }
    ]
  }, */

  // 图标
/*   {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.icon,
    component: Layout,
    children: [
      {
        path: "/icon",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.builtInIcon,
        component: Icon,
        children: []
      }
    ]
  }, */

  // 穿梭框
/*   {
    path: "/",
    iconCls: "fa fa-exchange", // 图标样式class
    name: routeName.shuttleBox,
    component: Layout,
    children: [
      {
        path: "/transfer",
        iconCls: "fa fa-sign-in", // 图标样式class
        name: routeName.demoShuttle,
        component: Transfer,
        children: []
      }
    ]
  }, */

  // 权限管理
/*   {
    path: "/",
    iconCls: "fa fa-universal-access", // 图标样式class
    name: routeName.permissions,
    component: Layout,
    children: [
      {
        path: "/pagePermissions",
        iconCls: "fa fa-expeditedssl", // 图标样式class
        name: routeName.pageControl,
        component: pagePermissions,
        children: []
      },
      {
        path: "/btnPermissions",
        iconCls: "fa fa-toggle-on", // 图标样式class
        name: routeName.btnControl,
        component: btnPermissions,
        children: []
      }
    ]
  }, */

  // 表格
 /*  {
    path: "/",
    iconCls: "fa fa-newspaper-o", // 图标样式class
    name: routeName.table,
    component: Layout,
    children: [
      {
        path: "/dataTable",
        iconCls: "fa fa-sliders", // 图标样式class
        name: routeName.multiDataTable,
        component: DataTable,
        children: []
      },
      {
        path: "/filterTable",
        iconCls: "fa fa-sort-amount-asc", // 图标样式class
        name: routeName.filterTable,
        component: FilterTable,
        children: []
      },
      {
        path: "/dragTabe",
        iconCls: "fa fa-hand-stop-o", // 图标样式class
        name: routeName.dragSort,
        component: DragTable,
        children: []
      }
    ]
  }, */

  // 多级目录   班级管理演示
  {
    path: "/",
    iconCls: "fa fa-question-circle",
    name: routeName.multiDirectory,
    component: Layout,
    children: [
      {
        path: "/Home",
        iconCls: "fa fa-bar-chart",
        name: routeName["menu2-1"],
        component:()=>import ('../views/Home'),
        children: []
      },
      {
        path: "/BranchSchool",
        iconCls: "fa fa-th-large",
        name: routeName["menu2-2"],
        component:()=>import ('../views/BranchSchool'),
        children: []
      },
      {
        path: "/ClassAndGrade",
        iconCls: "fa fa-th-large",
        name: routeName["menu2-3"],
        component:()=>import ('../views/ClassAndGrade'),
        children: []
      },
      {
        
        path: "/Subject",
        iconCls: "fa fa-star",
        name: routeName["menu2-4"],
        component:()=>import ('../views/Subject'),
        children: []
      },
      {
        
        path: "/Teacher",
        iconCls: "fa fa-black-tie",
        name: routeName["menu2-5"],
        component:()=>import ('../views/Teacher'),
        children: []
      },
      {
        
        path: "/Student",
        iconCls: "fa fa-group",
        name: routeName["menu2-6"],
        component:()=>import ('../views/Student'),
        children: []
      },
      {
        
        path: "/Inform",
        iconCls: "fa fa-volume-up",
        name: routeName["menu2-7"],
        component:()=>import ('../views/Inform'),
        children: []
      },
      {
        
        path: "/Work",
        iconCls: "fa fa-pencil-square-o",
        name: routeName["menu2-8"],
        component:()=>import ('../views/Work'),
        children: []
      },
      {
        
        path: "/ClockIn",
        iconCls: "fa fa-calendar-check-o",
        name: routeName["menu2-9"],
        component:()=>import ('../views/ClockIn'),
        children: []
      },
      {
        
        path: "/FillInAForm",
        iconCls: "fa fa-list",
        name: routeName["menu2-10"],
        component:()=>import ('../views/FillInAForm'),
        children: []
      },
      {
        
        path: "/Exam",
        iconCls: "fa fa-check",
        name: routeName["menu2-11"],
        component:()=>import ('../views/Exam'),
        children: []
      },
      {
        
        path: "/PhotoAlbum",
        iconCls: "fa fa-image",
        name: routeName["menu2-12"],
        component:()=>import ('../views/PhotoAlbum'),
        children: []
      },
      {
        
        path: "/Template",
        iconCls: "fa fa-file-text-o",
        name: routeName["menu2-13"],
        component:()=>import ('../views/Template'),
        children: []
      },
      {
        
        path: "/Page",
        iconCls: "fa fa-file-text-o",
        name: routeName["menu2-14"],
        component:()=>import ('../views/Page'),
        children: []
      },
      {
        
        path: "/Employ",
        iconCls: "fa fa-file-text-o",
        name: routeName["menu2-15"],
        component:()=>import ('../views/Employ'),
        children: []
      },



    ]
  },

  // 测试
  {
       path: "/e",
        iconCls: "fa fa-file-text-o",
        name: routeName.ceshi,
        component:()=>import ('../views/Test'),
        children: []
  },

  // 上传
 /*  {
    path: "/",
    iconCls: "fa fa-cloud-upload", // 图标样式class
    name: routeName.upload,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        path: "/upload",
        iconCls: "el-icon-upload2", // 图标样式class
        name: routeName.fileUpload,
        component: Upload,
        children: []
      }
    ]
  }, */

  // 编辑器
/*   {
    path: "/",
    iconCls: "el-icon-edit", // 图标样式class
    name: routeName.editor,
    component: Layout,
    meta: {role: ["superAdmin", "admin"]},
    children: [
      {
        path: "/markdown",
        iconCls: "fa fa-file-code-o", // 图标样式class
        name: routeName.markdown,
        component: Markdown,
        children: []
      },
      {
        path: "/wangeditor",
        iconCls: "fa fa-file-code-o", // 图标样式class
        name: routeName.wangeditor,
        component: WangeditorView,
        children: []
      }
    ]
  }, */

  //系统设置
 /*  {
    path: "/",
    iconCls: "el-icon-setting", // 图标样式class
    name: routeName.systemSettings,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        path: "/navClassifies",
        iconCls: "el-icon-menu", // 图标样式class
        name: routeName.navMenu,
        component: NavClassify,
        children: []
      }
    ]
  }, */
  { path: "*",
    redirect: "/404",
    hidden: true,
    children: []
  }

]
export default new Router({
  routes: defaultRouter
})
export {defaultRouter, addRouter}
